package com.ruoyi.jjm.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.jjm.mapper.ClientUserOrderMapper;
import com.ruoyi.jjm.domain.ClientUserOrder;
import com.ruoyi.jjm.service.IClientUserOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 村民购煤订单Service业务层处理
 * 
 * @author tsr
 * @date 2020-07-15
 */
@Service
public class ClientUserOrderServiceImpl implements IClientUserOrderService 
{
    @Autowired
    private ClientUserOrderMapper clientUserOrderMapper;

    /**
     * 查询村民购煤订单
     * 
     * @param id 村民购煤订单ID
     * @return 村民购煤订单
     */
    @Override
    public ClientUserOrder selectClientUserOrderById(Long id)
    {
        return clientUserOrderMapper.selectClientUserOrderById(id);
    }

    /**
     * 查询村民购煤订单列表
     * 
     * @param clientUserOrder 村民购煤订单
     * @return 村民购煤订单
     */
    @Override
    public List<ClientUserOrder> selectClientUserOrderList(ClientUserOrder clientUserOrder)
    {
        return clientUserOrderMapper.selectClientUserOrderList(clientUserOrder);
    }

    @Override
    public List<ClientUserOrder> searchByFilter(ClientUserOrder clientUserOrder) {
        return clientUserOrderMapper.searchByFilter(clientUserOrder);
    }

    /**
     * 新增村民购煤订单
     * 
     * @param clientUserOrder 村民购煤订单
     * @return 结果
     */
    @Override
    public int insertClientUserOrder(ClientUserOrder clientUserOrder)
    {
        clientUserOrder.setCreateTime(DateUtils.getNowDate());
        return clientUserOrderMapper.insertClientUserOrder(clientUserOrder);
    }

    /**
     * 修改村民购煤订单
     * 
     * @param clientUserOrder 村民购煤订单
     * @return 结果
     */
    @Override
    public int updateClientUserOrder(ClientUserOrder clientUserOrder)
    {
        clientUserOrder.setUpdateTime(DateUtils.getNowDate());
        return clientUserOrderMapper.updateClientUserOrder(clientUserOrder);
    }

    /**
     * 删除村民购煤订单对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteClientUserOrderByIds(String ids)
    {
        return clientUserOrderMapper.deleteClientUserOrderByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除村民购煤订单信息
     * 
     * @param id 村民购煤订单ID
     * @return 结果
     */
    @Override
    public int deleteClientUserOrderById(Long id)
    {
        return clientUserOrderMapper.deleteClientUserOrderById(id);
    }

    @Override
    public ClientUserOrder sumOrder(Long villageId) {
        return clientUserOrderMapper.sumOrder(villageId);
    }

    /**
     * 更新供应商订单ID
     * @param supplierOrderId
     * @param status
     */

    @Override
    public void updateSupplierOrderIdByStatus(Long supplierOrderId,Integer status,Long villageId){
        clientUserOrderMapper.updateSupplierOrderIdByStatus(supplierOrderId,status,villageId);
    }

    @Override
    public double countCunTotal(Long villageId) {
        return clientUserOrderMapper.countCunTotal(villageId);
    }

    @Override
    public double countXiangTotal(Long xiangId) {
        return  clientUserOrderMapper.countXiangTotal(xiangId);
    }

    @Override
    public Long countOrderConnfirmed(Long xiangId) {
        return clientUserOrderMapper.countOrderConnfirmed(xiangId);
    }
}
